<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function unique(str){
            var newStr = '';
            var len = str.length;
            for(var i=0;i<len;i++){
                if(newStr.indexOf(str[i]) == -1){//indexOf去重
                    newStr = newStr + str[i]
                }
            }
            return newStr
        }
        var a = unique('abbcdcefgh');
        console.log(a)
    </script>
</body>
</html>